<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="com.shsh.safemanage.util.Util"%>
<%@page import="com.shsh.safemanage.model.Role"%>
<%@page import="com.shsh.safemanage.dao.RoleDao"%>
<%@page import="com.shsh.safemanage.util.RequestUtil"%>
<%@page import="com.shsh.safemanage.util.Constants"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%
	{
	session.removeAttribute(Constants.SESSION_WEAK_REPORT);
	session.removeAttribute(Constants.SESSION_ESCALATE_USER);
	session.removeAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1);
	
	Integer year = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_YEAR, 0);
	Integer month = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_MONTH, 0);
	
	User sessionUser = (User)session.getAttribute(Constants.SESSION_USER);
	
	RoleDao roleDao = DaoCreator.createRoleDao();
	DepartmentDao departDao = DaoCreator.createDepartmentDao();
	
	Role userRole = roleDao.getRoleByUserID(sessionUser.getId());
	
	if(userRole.getRoleType() == Constants.ROLE_TYPE_YIXIANYUANGONG) {
		return;
	}
	
	Department1 depart1 = departDao.getDepartment1ByID(sessionUser.getDepartment1ID());
%>

<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 综合管理&gt;&gt;十大薄弱环节汇总表
</div>

<div class="content" style="">
	<div class="apptab">
		<table width="100%" border="0" cellpadding="0" cellspacing="0"
			style="font-size: 12px; color: #000; line-height: 25px;">
			<tr>
				<td width="13" class="appbg">&nbsp;</td>
				<td width="97" class="appbg"><img src="images/trace.gif"
					style="vertical-align: middle;" />填报</td>
				<td width="554" class="appbg">&nbsp;</td>
				<td colspan="2" class="appbg">&nbsp;</td>
			</tr>
			<tr>
				<td width="13" height="40">&nbsp;</td>
				<td colspan="3">
					<span style="margin-left: 30px">生成类型：</span>
					<select name="weakReportType" id="weakReportType">
<%
if(depart1.getDepartmentType() == Constants.DEPARTMENT_TYPE_SHIYEBU) {
%>
						<option value="1">一线员工积分台账</option>
<%
}
%>
						<option value="2">管理人员积分台帐</option>
						<option value="3">单位积分台帐</option>
					</select>
					
					<span style="margin-left: 30px">作业部：</span>
					<span id="depart1Name"> 
					<%=Util.getDisplay(sessionUser.getDepartment1Name(), "") %>
					</span> 
					<span style="margin-left: 10px">装置：</span> 
					<span id="equipOfDepartSpan">
						<%@include file="/equip_select/equipment_of_depart_select_section.jsp"%>
					</span>
					 
					<br />
					
					<span style="margin-left: 30px">填报日期区间：</span> <input type="text" id="dateStart"
					size="15"
					onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'dateStart\')||\'2050-12-31\'}'})" />-<input
					type="text" id="dateEnd" size="15"
					onfocus="WdatePicker({minDate:'#F{$dp.$D(\'dateEnd\')}',maxDate:'2050-12-31'})" />
				</td>
				<td width="14">&nbsp;</td>
			</tr>
			<tr>
				<td width="13" height="40">&nbsp;</td>
				<td colspan="3" style="text-align: center;">
					<input type="button" onclick="startWrite()" value="填 报"/>
				</td>
				<td width="14">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="5" height="20">&nbsp;</td>
			</tr>
		</table>
	</div>
	
	<div class="apptab" id="problemBrowseListTD">
	</div>
</div>
<script type="text/javascript">
function checkWeakType(problemID, weakType){
	var checkedID = '#weakType' + problemID + '_' + weakType;
	var isChecked = $(checkedID).attr('checked');
	var valueID = 'noneWorkTimeValue'+problemID;
	var noneWorkTime = getElementValueByID(valueID);
	
	var checkID0 = '#weakType' + problemID + '_' + 0;
	var checkID1 = '#weakType' + problemID + '_' + 1;
	var checkID2 = '#weakType' + problemID + '_' + 2;
	$(checkID0).attr('checked', false);
	$(checkID1).attr('checked', false);
	$(checkID2).attr('checked', false);
	
	if(isChecked != true){
		weakType = 2;
	}
	loadPageSection('<%=request.getContextPath()%>/weak/refresh_write_report_list_process.jsp', 'problemBrowseListTD', 
			{
				problemID : problemID,
				weakType: weakType,
				noneWorkTime: noneWorkTime
			},
			true
		);
}

function checkDelete(problemID){
	var checkedID = '#delete' + problemID;
	var needDelete = $(checkedID).attr('checked');
	var valueID = 'noneWorkTimeValue'+problemID;
	var noneWorkTime = getElementValueByID(valueID);
	loadPageSection('<%=request.getContextPath()%>/weak/refresh_write_report_list_process.jsp', 'problemBrowseListTD', 
			{
				problemID : problemID,
				needDelete: needDelete,
				noneWorkTime: noneWorkTime
			},
			true
		);
}
function checkReverse(problemID){
	var checkedID = '#delete' + problemID;
	var reverseID = '#reverse' + problemID;
	var valueID = 'noneWorkTimeValue'+problemID;
	var noneWorkTime = getElementValueByID(valueID);
	
	$(checkedID).attr('checked', false);
	
	var needDelete = $(checkedID).attr('checked');
	loadPageSection('<%=request.getContextPath()%>/weak/refresh_write_report_list_process.jsp', 'problemBrowseListTD', 
			{
				problemID : problemID,
				needDelete: needDelete,
				noneWorkTime: noneWorkTime
			},
			true
		);	
}
function checkNoneWorkTime(problemID){
	var checkedID = '#noneWorkTimeCheck' + problemID;
	var valueID = 'noneWorkTimeValue'+problemID;
	var hasNoneWorkTime = $(checkedID).attr('checked');
	var noneWorkTime = getElementValueByID(valueID);
	loadPageSection('<%=request.getContextPath()%>/weak/refresh_write_report_list_process.jsp', 'problemBrowseListTD', 
			{
				problemID : problemID,
				hasNoneWorkTime: hasNoneWorkTime,
				noneWorkTime: noneWorkTime
			},
			true
		);
}

function changeEquip(){
	//empty.
}

function chooseProcessMethod(method) {
	//empty.
	//convertProblem();
}

function createWeakParamJSON(){
	var paramJSON = '';	
	$('input:text').each(function(){
		if(this.name!=null && this.name!='') {
			var paramName = "'" + this.name + "'" ;
			var paramValue =  "'" + $(this).attr('value') + "'";
			paramJSON =  paramJSON + "," + paramName + ":" + paramValue;
		}
	});
	
	paramJSON = paramJSON.substring(1);
	paramJSON = '{' + paramJSON + '}';

	return paramJSON;
}

function writeWeakReport(){
	var paramJSON = createWeakParamJSON();
	
	var processMethod = 0;
	var processRadio1 = document.getElementById('processRadio1');
	var processRadio3 = document.getElementById('processRadio3');
	if (processRadio3 != null && processRadio3.checked) {
		processMethod = 3;
	} else 	if (processRadio1 != null && processRadio1.checked) {
		processMethod = 1;
	}

	var weakReportType = getElementValueByID('weakReportType');
	var problemTitle = '';
	if(weakReportType == 1){
		var depart1Name = $('#depart1Name').text();
		var equipName = $('#equipID').find("option:selected").text();
		problemTitle = '《' + depart1Name+ equipName + '一线员工积分台账》';
	} else if(weakReportType == 2){
		problemTitle = '《管理人员积分台帐》';	
	} else if(weakReportType == 3){
		problemTitle = '《单位积分台帐》';	
	}
	
	if ($.dialog.confirm('您确定提交此报告吗？', function(){
		openWaitingDialog('waitingDialog');
		$.ajax({
			type:'post',
			url:'<%=request.getContextPath()%>/weak/write_report_process.jsp',
			data:{
				paramJSON: paramJSON,
				processMethod: processMethod,
				transferID: '',
				feedback: '',
				problemTitle: problemTitle
			},
			success:function(data,state,xmlhttp){
				var obj = null;
				try {
					obj = eval('(' + data + ')');
				} catch (e) {
				}
				if (typeof(obj.isSuccess) != 'undefined') {
					closeWaitingDialog('waitingDialog');
					if (obj.isSuccess == 'true') {
						$.dialog('报告填报成功！', function() { loadPageSection('<%=request.getContextPath()%>/weak/write_report.jsp', 'mainContentDiv'); });
					} else {
						$.dialog.alert(obj.error);
					}
				}
			}
		});
	}, function(){}));
}

function cancelWriteWeakReport(){
	loadPageSection('<%=request.getContextPath()%>/weak/write_report.jsp', 'mainContentDiv');
}

function startWrite(){
	var weakReportType = getElementValueByID('weakReportType');
	var dateStart = getElementValueByID('dateStart');
	var dateEnd = getElementValueByID('dateEnd');
	
	if(dateStart == null || dateStart == '') {
		$.dialog.alert('请选择开始日期');
		return;
	}
	
	if(dateEnd == null || dateEnd == '') {
		$.dialog.alert('请选择结束日期');
		return;
	}

	openWaitingDialog('waitingDialog');
	loadPageSection('<%=request.getContextPath()%>/weak/prepare_report_list_process.jsp', 'problemBrowseListTD', 
			{
				equipID : getElementValueByID('equipID'),
				weakReportType: weakReportType,
				dateStart: dateStart,
				dateEnd: dateEnd 
			},
			true
		);
}
</script>
<%
}
%>